{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import shutil\n",
    "import os\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = pd.read_csv('labels.csv')\n",
    "path = 'for_train'\n",
    "\n",
    "if os.path.exists(path):\n",
    "    shutil.rmtree(path)\n",
    "\n",
    "for i, (fname, breed) in df.iterrows():\n",
    "    path2 = '%s/%s' % (path, breed)\n",
    "    if not os.path.exists(path2):\n",
    "        os.makedirs(path2)\n",
    "    os.symlink('train/%s.jpg' % fname, '%s/%s.jpg' % (path2, fname))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = pd.read_csv('sample_submission.csv')\n",
    "path = 'for_test'\n",
    "breed = '0'\n",
    "\n",
    "if os.path.exists(path):\n",
    "    shutil.rmtree(path)\n",
    "\n",
    "for fname in df['id']:\n",
    "    path2 = '%s/%s' % (path, breed)\n",
    "    if not os.path.exists(path2):\n",
    "        os.makedirs(path2)\n",
    "    os.symlink('test/%s.jpg' % fname, '%s/%s.jpg' % (path2, fname))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
